<?php
session_start();
class indexController extends Controller{
    public function isLogin(){
        $user = isset($_SESSION['user']) ? $_SESSION['user'] : null;
        if($user){
            $this->assign('admin',$user);
           $this->display('index.tpl');
           
        }else{
            $this->display('login.tpl');
        }
        
    }

    public function login(){
         $indexM = new indexModel();
         $user = $this->post('user');
         $pwd = $this->post('pwd');
         $islog = $indexM->login($user,$pwd);
         if($islog){
            $_SESSION['user'] = $islog[0];
         }
         self::isLogin();

    }

    public function logout(){
        session_unset();
        $this->isLogin();
    }
	
	
	
	public function indeximg(){
		$this->display('velcome.tpl');
	}
}